﻿using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Xml.Linq;
using LEShortcut.Annotations;

namespace LEShortcut.Models.Views.Pages
{
    public class HomeViewContext : INotifyPropertyChanged
    {
        private string _description;
        private string _exeutionPath;
        private string _fileName;
        private string _filePath;
        private List<XElement> _leConfig;

        public AppConfig Config { get; set; }
        public int IconIndex { get; set; }
        public string IconPath { get; set; }
        public string ChoosedProfile { get; set; }

        public string FilePath
        {
            get { return _filePath; }
            set
            {
                if (value != _filePath)
                {
                    _filePath = value;
                    OnPropertyChanged();
                }
            }
        }

        public string FileName
        {
            get { return _fileName; }
            set
            {
                if (value != _fileName)
                {
                    _fileName = value;
                    OnPropertyChanged();
                }
            }
        }

        public string Description
        {
            get { return _description; }
            set
            {
                if (value != _description)
                {
                    _description = value;
                    OnPropertyChanged();
                }
            }
        }

        public string ExeutionPath
        {
            get { return _exeutionPath; }
            set
            {
                if (value != _exeutionPath)
                {
                    _exeutionPath = value;
                    OnPropertyChanged();
                }
            }
        }

        public List<XElement> LeConfig
        {
            get { return _leConfig; }
            set
            {
                if (!value.Equals(_leConfig))
                {
                    _leConfig = value;
                    OnPropertyChanged();
                }
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;

        [NotifyPropertyChangedInvocator]
        protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
        }
    }
}